import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(ElementUI)

// 全局默认 Message 带关闭按钮
const message = function(options) {
  if (typeof options === 'string') {
    options = {
      message: options
    }
  }
  options.showClose = true
  return ElementUI.Message(options)
}
;['success', 'warning', 'info', 'error'].forEach(type => {
  message[type] = options => {
    if (typeof options === 'string') {
      options = {
        message: options
      }
    }
    options.type = type
    options.showClose = true
    return ElementUI.Message(options)
  }
})
Vue.prototype.$message = message
Vue.config.productionTip = false

Vue.prototype.$bus = new Vue()

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
